package com.ruoyi.system.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;

/**
 * 银行日记账对象 qwh_bank_journal
 * 
 * @author ruoyi
 * @date 2025-02-25
 */
public class QwhBankJournal extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键 */
    private Long id;

    /** 银行外键 */
    private Long bankId;

    /** 日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date createDate;


    @JsonFormat(pattern = "yyyy-MM-dd")
private Date beginCreateDate;


    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endCreateDate;


    /** 摘要 */
    @Excel(name = "摘要")
    private String abstracts;

    /** 收支类别 */
    @Excel(name = "收支类别")
    private Long inoutId;

    /** 收入 */
    @Excel(name = "收入")
    private BigDecimal income;

    /** 支出 */
    @Excel(name = "支出")
    private BigDecimal disburse;

    /** 余额 */
    @Excel(name = "余额")
    private BigDecimal balance;

    /** 往来单位 */
    @Excel(name = "往来单位")
    private Long correspondentId;

    /** 项目 */
    @Excel(name = "项目")
    private Long itemId;

    /** 部门 */
    @Excel(name = "部门")
    private Long sectionId;

    /** 经手人 */
    @Excel(name = "经手人")
    private Long personId;

    /** 关联凭证 */
    @Excel(name = "关联凭证")
    private String proof;

    /** 往来账号 */
    @Excel(name = "往来账号")
    private String currentAccount;

    /** 结算方式 */
    @Excel(name = "结算方式")
    private Long settlementId;

    /** 票据号 */
    @Excel(name = "票据号")
    private String ticket;

    /** 交易流水号 */
    @Excel(name = "交易流水号")
    private String tradingStatement;

    /** 日记账序号 */
    @Excel(name = "日记账序号")
    private String journalSerial;


    private int insertAfter;
private int bankType;
    // 自定义校验逻辑
    public void validate() {
        if (income == null && disburse == null) {
            throw new IllegalArgumentException("收入和支出必须填写一个");
        }
        if (income != null && disburse != null) {
            throw new IllegalArgumentException("收入和支出只能填写一个");
        }


    // 校验收支类别与收入、支出字段的一致性
        if (inoutId==1) {
    if (income == null || disburse != null) {
        throw new IllegalArgumentException("收支类别为收入时，必须填写收入字段且支出字段为空");
    }
} else if (inoutId==2) {
    if (disburse == null || income != null) {
        throw new IllegalArgumentException("收支类别为支出时，必须填写支出字段且收入字段为空");
    }
} else {
    throw new IllegalArgumentException("收支类别必须为收入或支出");
}
}




    public Date getBeginCreateDate() {
        return beginCreateDate;
    }

    public void setBeginCreateDate(Date beginCreateDate) {
        this.beginCreateDate = beginCreateDate;
    }

    public Date getEndCreateDate() {
        return endCreateDate;
    }

    public void setEndCreateDate(Date endCreateDate) {
        this.endCreateDate = endCreateDate;
    }


    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setBankId(Long bankId) 
    {
        this.bankId = bankId;
    }

    public Long getBankId()
    {
        return bankId;
    }
    public void setCreateDate(Date createDate) 
    {
        this.createDate = createDate;
    }

    public Date getCreateDate() 
    {
        return createDate;
    }
    public void setAbstracts(String abstracts) 
    {
        this.abstracts = abstracts;
    }

    public String getAbstracts() 
    {
        return abstracts;
    }
    public void setInoutId(Long inoutId) 
    {
        this.inoutId = inoutId;
    }

    public Long getInoutId() 
    {
        return inoutId;
    }
    public void setIncome(BigDecimal income) 
    {
        this.income = income;
    }

    public BigDecimal getIncome() 
    {
        return income;
    }
    public void setDisburse(BigDecimal disburse) 
    {
        this.disburse = disburse;
    }

    public BigDecimal getDisburse() 
    {
        return disburse;
    }
    public void setBalance(BigDecimal balance) 
    {
        this.balance = balance;
    }

    public BigDecimal getBalance() 
    {
        return balance;
    }
    public void setCorrespondentId(Long correspondentId) 
    {
        this.correspondentId = correspondentId;
    }

    public Long getCorrespondentId() 
    {
        return correspondentId;
    }
    public void setItemId(Long itemId) 
    {
        this.itemId = itemId;
    }

    public Long getItemId() 
    {
        return itemId;
    }
    public void setSectionId(Long sectionId) 
    {
        this.sectionId = sectionId;
    }

    public Long getSectionId() 
    {
        return sectionId;
    }
    public void setPersonId(Long personId) 
    {
        this.personId = personId;
    }

    public Long getPersonId() 
    {
        return personId;
    }
    public void setProof(String proof) 
    {
        this.proof = proof;
    }

    public String getProof() 
    {
        return proof;
    }
    public void setCurrentAccount(String currentAccount) 
    {
        this.currentAccount = currentAccount;
    }

    public String getCurrentAccount() 
    {
        return currentAccount;
    }
    public void setSettlementId(Long settlementId) 
    {
        this.settlementId = settlementId;
    }

    public Long getSettlementId() 
    {
        return settlementId;
    }
    public void setTicket(String ticket) 
    {
        this.ticket = ticket;
    }

    public String getTicket() 
    {
        return ticket;
    }
    public void setTradingStatement(String tradingStatement) 
    {
        this.tradingStatement = tradingStatement;
    }

    public String getTradingStatement() 
    {
        return tradingStatement;
    }
    public void setJournalSerial(String journalSerial) 
    {
        this.journalSerial = journalSerial;
    }

    public String getJournalSerial() 
    {
        return journalSerial;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("bankId", getBankId())
            .append("createDate", getCreateDate())
            .append("abstracts", getAbstracts())
            .append("inoutId", getInoutId())
            .append("income", getIncome())
            .append("disburse", getDisburse())
            .append("balance", getBalance())
            .append("correspondentId", getCorrespondentId())
            .append("itemId", getItemId())
            .append("sectionId", getSectionId())
            .append("personId", getPersonId())
            .append("proof", getProof())
            .append("currentAccount", getCurrentAccount())
            .append("settlementId", getSettlementId())
            .append("ticket", getTicket())
            .append("remark", getRemark())
            .append("tradingStatement", getTradingStatement())
            .append("journalSerial", getJournalSerial())
            .toString();
    }
}
